from kivy.app import App
from kivy.uix.widget import Widget
from kivy.graphics import Color, Rectangle

class MyWidget(Widget):
    def __init__(self, **kwargs):
        super(MyWidget, self).__init__(**kwargs)

        # 在画布上绘制一个矩形
        with self.canvas:
            Color(1, 0, 0, 1)  # 红色
            Rectangle(pos=(100, 100), size=(200, 150))

class MyApp(App):
    def build(self):
        return MyWidget()

if __name__ == '__main__':
    MyApp().run()